#ifndef _GRID_H_
#define _GRID_H_

#include "site.h"
#include "filechecker.h"
//ALTERADO

class Grid {
	private:
		/*Grid name*/
		const char *name;		
		/*Set of sites*/		
		Site **sites;
		/*Set of intersite-links*/
		Link **links;
		/*Grid routes*/
		SG_Resource *routes;
		/*Counters to sites, links and routes*/
		int numberOfSites;
		int numberOfLinks;
		int numberOfRoutes;
	public:
		/*Constructor. Create an empty grid (no sites nor links)*/
		Grid(const char *name);
		/*Destructor*/
		~Grid();
		/*Add a site to the grid*/
		void addSite(const char *site_domain, long double intralink_bw, long double interlink_lat, long double interlink_bw, long double interlink_bw_lim);
		void addSite(const char *site_domain, const char *intralink_bw, long double intralink_bw_offset,  const char *interlink_lat, long double interlink_lat_offset, const char *interlink_bw, long double interlink_bw_offset, const char *interlink_bw_lim, long double interlink_bw_lim_offset, const char *intralink_bw_error, const char *interlink_lat_error, const char *interlink_bw_error, const char *intralink_bw_forecast=NULL, const char *interlink_lat_forecast=NULL, const char *interlink_bw_forecast=NULL, const char *interlink_bw_lim_forecast=NULL);		
		/*Get the name of the grid*/
		const char *getName();
		/*Get the number of sites*/
		int getNumberOfSites();
		/*Get the number of inter-site links*/
		int getNumberOfLinks();
		/*Get the number of routes*/
		int getNumberOfRoutes();
		/*Get a inter-site link by Index*/
		Link *getLinkByIndex(int index);
		/*Get a site by index*/
		Site *getSiteByIndex(int index);
		/*Get a site by its domain name*/
		Site *getSiteByDomain(const char *site_domain);
		/*Gets the route between from the base site to a given site*/
		SG_Resource getRouteToSite( int site_index);
		/*Get the bottleneck link of a route to a given site*/
		Link *getBottleneckLinkOfRouteToSite(int site_index);
		/*Verify if the grid is totally busy*/
		bool isTotallyBusy();
		/*Verify if the sites that have available information are busy (If the Grid considered by XSufferage is Totally Busy)*/
		bool allSitesWithAllAvailableInformationAreBusy();
		/*gets total number of Processors*/
		int getTotalNumberOfProcessors();
		/*Get the current number of tasks allocated to this Grid*/		
		int getNumberOfAllocatedTasks();		
		/*Update the offset of the resources*/
		void updateOffsetOfAllResources(long double new_offset);
		
		//Get processor by name
		Processor *getProcessorByName(const char *proc_name);
};

#endif //_GRID_H_
